// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'promise-polyfill/src/polyfill';
import FastClick from 'fastclick';
import './components/assets/index.less';
import Vue from 'vue';
import Components from './components';
import App from './App';
import router from './router';
import store from './store';
import browser from './utils/browser';



// 时间格式
import moment from 'moment';
Vue.prototype.$moment = moment;


Vue.use(Components);

if ('addEventListener' in document) {
  document.addEventListener('DOMContentLoaded', function () {
    FastClick.attach(document.body);
  }, false);
  FastClick.prototype.focus = function (targetElement) {
    var length;
    //兼容处理:在iOS7中，有一些元素（如date、datetime、month等）在setSelectionRange会出现TypeError
    //这是因为这些元素并没有selectionStart和selectionEnd的整型数字属性，所以一旦引用就会报错，因此排除这些属性才使用setSelectionRange方法
    if (browser.isIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month' && targetElement.type !== 'email') {
      length = targetElement.value.length;
      targetElement.setSelectionRange(length, length);
      /*修复bug ios 11.3不弹出键盘，这里加上聚焦代码，让其强制聚焦弹出键盘*/
      targetElement.focus();
    } else {
      targetElement.focus();
    }
  };
}

Vue.config.productionTip = false;




sessionStorage.setItem("corpId", decodeURIComponent((new RegExp('[?|&]' + 'corpId' + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || '');
sessionStorage.setItem("appKey", decodeURIComponent((new RegExp('[?|&]' + 'appKey' + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || '');
sessionStorage.setItem("appId", decodeURIComponent((new RegExp('[?|&]' + 'appId' + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || '');
new Vue({
  el: '#app',
  router,
  store,
  components: {
    App
  },
  template: '<App/>'
});
